package com.huffman.smart_picture.controller;

import com.huffman.smart_picture.common.auth.annotation.CheckRole;
import com.huffman.smart_picture.common.base.reponse.ResponseResult;
import com.huffman.smart_picture.domain.constants.CommonConstant;
import com.huffman.smart_picture.domain.vo.manage.DashboardDataCountVo;
import com.huffman.smart_picture.domain.vo.manage.DashboardSpaceRatioVo;
import com.huffman.smart_picture.domain.vo.manage.DashboardUserRatioVo;
import com.huffman.smart_picture.service.ManageService;

import com.huffman.smart_picture.utils.ResponseUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zihan
 * @title 统计控制器
 * @date 2025/7/13
 */

@RestController
@RequestMapping("/manage")
public class ManageController {

    @Resource
    private ManageService manageService;

    @GetMapping("/dashboard/count")
    @ApiOperation(value = "用户总人数")
    @CheckRole(roles = {CommonConstant.ADMIN})
    public ResponseResult<Long> getUserCount() {
        DashboardDataCountVo dashboardDataCount = manageService.getDashboardDataCount();
        return ResponseUtil.success(dashboardDataCount);
    }

    @GetMapping("/user/ratio")
    @ApiOperation(value = "获取用户占比")
    @CheckRole(roles = {CommonConstant.ADMIN})
    public ResponseResult getNonVipRatio() {
        DashboardUserRatioVo dashboardUserRatio = manageService.getDashboardUserRatio();
        return ResponseUtil.success(dashboardUserRatio);
    }

    @GetMapping("/space/ratio")
    @ApiOperation(value = "获取空间类型占比")
    @CheckRole(roles = {CommonConstant.ADMIN})
    public ResponseResult getSpaceRatio() {
        DashboardSpaceRatioVo dashboardSpaceRatio = manageService.getDashboardSpaceRatio();
        return ResponseUtil.success(dashboardSpaceRatio);
    }

}
